package cn.syan.core.common;

/**
 * 错误信息
 *
 * @program: spring-1
 * @description: 错误信息
 * @author: 陈泰汶
 * @create: 2023-03-02 15:27
 **/

public class CoreException extends RuntimeException implements ResultCode {

  private String msg;
  private int code;


  public CoreException(int code, String msg) {
    super(code + ":" + msg, null, true, true);
    this.code = code;
    this.msg = msg;
  }

  public CoreException(ResultCode resultCode) {
    this(resultCode.getCode(), resultCode.getMsg());
  }

  public CoreException(ResultCode resultCode, Object... args) {
    this(resultCode.getCode(), String.format(resultCode.getMsg(), args));
  }

  public CoreException(ResultCode resultCode, String str, Boolean flag) {
    this(resultCode.getCode(), resultCode.getMsg() + ":" + str);
  }

  @Override
  public int getCode() {
    return code;
  }

  @Override
  public String getMsg() {
    return msg;
  }
}